package org.spring.learn.demo.annotation.injections.primary;

import org.spring.learn.project.dao.MyDao;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
@ComponentScan(
        {"org.spring.learn.project.controller",
        "org.spring.learn.project.service",
        "org.spring.learn.project.dao"}
)
public class MyConfig {

    @Primary
    @Bean("dao")
    public MyDao dao() {
        MyDao myDao = new MyDao();
        myDao.setFlag("2");
        return myDao;
    }

    @Bean("dao")
    public MyDao myDao() {
        MyDao myDao = new MyDao();
        myDao.setFlag("2");
        return myDao;
    }
}
